<?php


namespace api\zmt\controller;


use api\zmt\model\actionModel;
use cmf\controller\RestBaseController;

class actionController extends RestBaseController
{
    public function index(){
        $data = input();
        $model = actionModel::where('mobile',$data['mobile'])->find();
        if ($model){
            return success('查询收获地址成功',$model);
        }else{
            return error('查询失败');
        }

    }

    public function add(\think\Request $request){
        if (request()->isPost()){
            $data = request()->post();
            $data['user_id'] = $request->userId;
            $model = actionModel::create($data);
            if ($model){
                return success('添加成功',$model);
            }
        }
    }

    public function edit(){
        if (request()->isPost()){
            $data = request()->post();
            $model = actionModel::where('mobile',$data['mobile'])->find();
            $model->name = $data['name'];
            $model->mobile = $data['mobile'];
            $model->location = $data['location'];
            $model->address = $data['address'];
            if ($model->save()){
                return success('修改成功',$model);
            }
        }
    }

}